/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Registrasi.java
 *
 * Created on Oct 7, 2012, 4:08:00 PM
 */
package View;

import Controller.ControlData;
import Data.Pasien;
import TableModel.pasienTableModel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;

/**
 *
 * @author a9uszT
 */
public class Registrasi extends javax.swing.JFrame {

    public Registrasi() {
        initComponents();
        tampilTable();
        cari_internalFrame.setVisible(false);
        GregorianCalendar gc = new GregorianCalendar();
        lahir_chooser.setDate(gc.getTime());
        ButtonGroup bg = new ButtonGroup();
        bg.add(l_radio);
        bg.add(p_radio);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cari_internalFrame = new javax.swing.JInternalFrame();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        pasien_table = new javax.swing.JTable();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        cariRM_TF = new javax.swing.JTextField();
        exit_internal = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        namaTF = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        idTF = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        alamatTF = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        telpTF = new javax.swing.JTextField();
        cari_button = new javax.swing.JButton();
        batal_button = new javax.swing.JButton();
        simpan_button = new javax.swing.JButton();
        keluar_button = new javax.swing.JButton();
        FAKULTAS_COMBO = new javax.swing.JComboBox();
        lahir_chooser = new com.toedter.calendar.JDateChooser();
        l_radio = new javax.swing.JRadioButton();
        p_radio = new javax.swing.JRadioButton();
        jLabel15 = new javax.swing.JLabel();
        nama_petugas = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        cari_internalFrame.setVisible(true);

        pasien_table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "nama", "alamat", "no telp", "fakultas/Bag"
            }
        ));
        pasien_table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pasien_tableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(pasien_table);

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel13.setText("Pencarian");

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel14.setText("masukan No RM");

        cariRM_TF.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                cariRM_TFKeyReleased(evt);
            }
        });

        exit_internal.setText("keluar");
        exit_internal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exit_internalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(478, Short.MAX_VALUE)
                .addComponent(exit_internal)
                .addGap(20, 20, 20))
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGap(110, 110, 110)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addGap(120, 120, 120)
                                    .addComponent(jLabel13))
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addComponent(jLabel14)
                                    .addGap(26, 26, 26)
                                    .addComponent(cariRM_TF, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 539, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addComponent(exit_internal)
                .addContainerGap(176, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel13)
                    .addGap(27, 27, 27)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel14)
                        .addComponent(cariRM_TF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(34, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout cari_internalFrameLayout = new javax.swing.GroupLayout(cari_internalFrame.getContentPane());
        cari_internalFrame.getContentPane().setLayout(cari_internalFrameLayout);
        cari_internalFrameLayout.setHorizontalGroup(
            cari_internalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cari_internalFrameLayout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        cari_internalFrameLayout.setVerticalGroup(
            cari_internalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cari_internalFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        getContentPane().add(cari_internalFrame, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 150, 570, 310));

        jPanel1.setBackground(new java.awt.Color(0, 153, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("registrasi"));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel3.setText("Registrasi");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel5.setText("Nama");

        namaTF.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                namaTFKeyReleased(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel4.setText("idPasien");

        idTF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idTFActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel6.setText("Alamat");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel7.setText("Jenis kelamin");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel8.setText("Tanggal Lahir");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel9.setText("Fakultas/Bag");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel10.setText("No telp");

        cari_button.setFont(new java.awt.Font("Arial Black", 1, 14));
        cari_button.setText("cari");
        cari_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cari_buttonActionPerformed(evt);
            }
        });

        batal_button.setFont(new java.awt.Font("Arial Black", 1, 14));
        batal_button.setText("batal");
        batal_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                batal_buttonActionPerformed(evt);
            }
        });

        simpan_button.setFont(new java.awt.Font("Arial Black", 1, 14));
        simpan_button.setText("simpan");
        simpan_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                simpan_buttonActionPerformed(evt);
            }
        });

        keluar_button.setFont(new java.awt.Font("Arial Black", 1, 14));
        keluar_button.setText("keluar");
        keluar_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keluar_buttonActionPerformed(evt);
            }
        });

        FAKULTAS_COMBO.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-----", "FST", "FARMASI", "FKIP", "PSIKOLOGI", "BK", "SASTRA", "TEOLOGI", "EKONOMI", "lain-lain" }));

        l_radio.setBackground(new java.awt.Color(0, 153, 255));
        l_radio.setText("Laki-Laki");

        p_radio.setBackground(new java.awt.Color(0, 153, 255));
        p_radio.setText("Perempuan");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel15.setText("Petugas :");

        nama_petugas.setFont(new java.awt.Font("Tahoma", 1, 12));
        nama_petugas.setText("nama");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(103, 103, 103)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8)
                            .addComponent(jLabel7)
                            .addComponent(jLabel10)
                            .addComponent(jLabel9))
                        .addGap(78, 78, 78)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(p_radio)
                                    .addComponent(l_radio))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 207, Short.MAX_VALUE)
                                .addComponent(jLabel15)
                                .addGap(6, 6, 6)
                                .addComponent(nama_petugas)
                                .addGap(51, 51, 51))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(FAKULTAS_COMBO, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(telpTF, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lahir_chooser, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(alamatTF, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(212, Short.MAX_VALUE))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(115, 115, 115)
                                .addComponent(idTF, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(131, 131, 131)
                                .addComponent(namaTF, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(212, Short.MAX_VALUE))))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(cari_button)
                        .addGap(99, 99, 99)
                        .addComponent(batal_button)
                        .addGap(53, 53, 53)
                        .addComponent(simpan_button)
                        .addGap(43, 43, 43)
                        .addComponent(keluar_button)))
                .addContainerGap(170, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(idTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(namaTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(alamatTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(30, 30, 30)
                        .addComponent(jLabel7))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lahir_chooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(l_radio)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(p_radio)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel9)
                        .addGap(22, 22, 22))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(telpTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(FAKULTAS_COMBO, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)))
                .addGap(19, 19, 19)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(batal_button)
                    .addComponent(simpan_button)
                    .addComponent(cari_button)
                    .addComponent(keluar_button))
                .addGap(48, 48, 48))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nama_petugas)
                    .addComponent(jLabel15))
                .addContainerGap(428, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 160, 720, -1));

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 30));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Sistem Informasi Rekam Medis");
        jPanel4.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 20, 490, 50));

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Poliklinik Sanata Dharma");
        jPanel4.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 70, -1, 28));

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("Jl. paingan, Maguwoharjo");
        jPanel4.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 110, -1, -1));

        jLabel12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/picture/usd.gif"))); // NOI18N
        jPanel4.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 150, 140));

        jLabel16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/picture/Vista_Blue_Withoutlogo_1600x1200.jpg"))); // NOI18N
        jLabel16.setText("jLabel10");
        jPanel4.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 720, 160));

        getContentPane().add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void batal_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_batal_buttonActionPerformed
        emptyList();
}//GEN-LAST:event_batal_buttonActionPerformed

    private void simpan_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simpan_buttonActionPerformed
        String cr = null;
        if (l_radio.isSelected()) {
            cr = "L";
        } else if (p_radio.isSelected()) {
            cr = "P";
        }
        Pasien passData = new Pasien();
        String id = idTF.getText();
        String nama = namaTF.getText();
        String alamat = alamatTF.getText();
        Date dt = lahir_chooser.getDate();
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
        String tanggalLahir = sdf.format(dt);
        String jenisKel = cr;
        String notelp = telpTF.getText();
        String FAKT = (String) FAKULTAS_COMBO.getSelectedItem();
        String faklts = FAKT;
        if (cr == null || id.equals("") || nama.equals("")
                || alamat.equals("") || tanggalLahir.equals("")
                || notelp.equals("") || faklts.equals("")) {
            JOptionPane.showMessageDialog(rootPane, "belum lengkap,harap isi form yang masih kosong",
                    "error", JOptionPane.ERROR_MESSAGE);

        } else {
            passData.setId(id);
            passData.setNama(nama);
            passData.setAlamat(alamat);
            passData.setTanggallahir(tanggalLahir);
            passData.setJeniskelamin(jenisKel);
            passData.setNotelp(notelp);
            passData.setFakultas(faklts);
            try {
                ControlData.input(passData);
                JOptionPane.showMessageDialog(rootPane, "berhasil disimpan");
                emptyList();
                idTF.requestFocus();
                ControlData.db.close();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(rootPane, "terjadi error" + ex.getMessage());
            }
        }

}//GEN-LAST:event_simpan_buttonActionPerformed

    private void keluar_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keluar_buttonActionPerformed
        int a = JOptionPane.showConfirmDialog(rootPane, "yakin keluar", "exit", JOptionPane.YES_NO_OPTION);
        if (a == 0) {
            JOptionPane.showMessageDialog(rootPane, "selesai ");
            dispose();
            disable();
        }
}//GEN-LAST:event_keluar_buttonActionPerformed

    private void idTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idTFActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idTFActionPerformed

    private void namaTFKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_namaTFKeyReleased
    }//GEN-LAST:event_namaTFKeyReleased

    private void cari_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cari_buttonActionPerformed
        cari_internalFrame.setVisible(true);
}//GEN-LAST:event_cari_buttonActionPerformed

    private void pasien_tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pasien_tableMouseClicked
        int i = pasien_table.getSelectedRow();
        String id = pasien_table.getValueAt(i, 0).toString();
        String nama = pasien_table.getValueAt(i, 1).toString();
        String fakt = pasien_table.getValueAt(i, 6).toString();
        RekamMedis rm = new RekamMedis();
        try {
            String idpetugas = ControlData.KodePegawai(nama_petugas.getText());
            System.out.println(id);
            RekamMedis.idPetugasRM.setText(idpetugas);
            RekamMedis.noRM_TF.setText(id);
            RekamMedis.nama_TF.setText(nama);
            RekamMedis.fak_TF.setText(fakt);
            RekamMedis.noRM_TF.setEditable(false);
            RekamMedis.noRM_TF.setEnabled(false);
            String namaPetugas = Frame_petugas.Nama_label.getText();
            RekamMedis.namaPetugas.setText(namaPetugas);
            RekamMedis.diagnosa_button.setEnabled(false);
            RekamMedis.therapi_button.setEnabled(false);
            RekamMedis.resep_button.setEnabled(false);

            RekamMedis.noRMotomatis();
            rm.tampilTableRM();
             ControlData.db.close();
        } catch (Exception ex) {
            Logger.getLogger(Registrasi.class.getName()).log(Level.SEVERE, null, ex);
        }
        ControlData.db.close();
        rm.setVisible(true);
        RekamMedis.diagnosa_button.setVisible(false);
        RekamMedis.therapi_button.setVisible(false);
        RekamMedis.resep_button.setVisible(false);

        RekamMedis.jLabel10.setVisible(true);
        RekamMedis.idPetugasRM.setVisible(true);
        RekamMedis.namaPetugas.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_pasien_tableMouseClicked

    private void cariRM_TFKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cariRM_TFKeyReleased
        String key = cariRM_TF.getText();
        try {
            List<Pasien> search = ControlData.ResultPasienSelected(key);
            pasienTableModel brngTableModel = new pasienTableModel(search);
            pasien_table.setModel(brngTableModel);
            tampilTable();
        } catch (Exception ex) {
            Logger.getLogger(Registrasi.class.getName()).log(Level.SEVERE, null, ex);
        }
        ControlData.db.close();
}//GEN-LAST:event_cariRM_TFKeyReleased

    private void exit_internalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exit_internalActionPerformed
        cari_internalFrame.setVisible(false);
    }//GEN-LAST:event_exit_internalActionPerformed

    private void emptyList() {
        idTF.setText("");
        namaTF.setText("");
        alamatTF.setText("");
        telpTF.setText("");
        FAKULTAS_COMBO.setSelectedItem("--");

    }

    private void tampilTable() {
        try {
            List<Pasien> lkat = ControlData.ResultPasien();
            pasienTableModel KTM = new pasienTableModel(lkat);
            pasien_table.setModel(KTM);
            ControlData.db.close();
        } catch (Exception ex) {
            Logger.getLogger(Registrasi.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Registrasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Registrasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Registrasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Registrasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new Registrasi().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox FAKULTAS_COMBO;
    private javax.swing.JTextField alamatTF;
    private javax.swing.JButton batal_button;
    private javax.swing.JTextField cariRM_TF;
    private javax.swing.JButton cari_button;
    private javax.swing.JInternalFrame cari_internalFrame;
    private javax.swing.JButton exit_internal;
    private javax.swing.JTextField idTF;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton keluar_button;
    private javax.swing.JRadioButton l_radio;
    private com.toedter.calendar.JDateChooser lahir_chooser;
    private javax.swing.JTextField namaTF;
    public static javax.swing.JLabel nama_petugas;
    private javax.swing.JRadioButton p_radio;
    private javax.swing.JTable pasien_table;
    private javax.swing.JButton simpan_button;
    private javax.swing.JTextField telpTF;
    // End of variables declaration//GEN-END:variables
}
